import { createApp } from 'vue'
// 引入入口文件
import App from '@/App.vue'
// 引入路由
import router from '@/router'
// 引入状态管理
import store from '@/store'
// 引入自定义指令
import directives from '@utils/directives'

// 引入 ElementUI Icon
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 引入 ElMessage 样式
import 'element-plus/theme-chalk/el-message.css'
import 'element-plus/theme-chalk/el-message-box.css'
// 引入全局样式
import '@/style/index'

const app = createApp(App)

// 遍历所有自定义指令注册
Object.keys(directives).forEach((key: string) => {
    app.directive(key, (directives as any)[key])
})

// 全局注册图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

app.use(router).use(store).mount('#app')
